#pragma once

#include <string>
#include <vector>

void CommonSplit(const std::string &s, char sep, std::vector<std::string> *ret)
{
    if (!ret) return;
    ret->clear();
    std::size_t split_idx = 0;
    std::size_t tmp_idx = 0;
    do
    {
        tmp_idx = s.find(sep, split_idx);
        if (tmp_idx != std::string::npos)
        {
            ret->emplace_back(s.substr(split_idx, tmp_idx - split_idx));
            split_idx = tmp_idx + 1;
        }
        else
        {
            ret->emplace_back(s.substr(split_idx));
        }
    } while (tmp_idx != std::string::npos);
}